﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DataAccessLayer;

namespace PresentationLayerMVC.Controllers
{
    [Authorize(Roles="Administrator")]
    public class RoomStatusController : Controller
    {
        //
        // GET: /RoomStatus/
        RoomStatusRepository roomStatusRepository = new RoomStatusRepository();

        public ActionResult Index()
        {
            IEnumerable<RoomStatu> roomStatuses = roomStatusRepository.GetAll();
            return View(roomStatuses);
        }

        //
        // GET: /RoomStatus/Details/5

        public ActionResult Details(int id)
        {
            RoomStatu roomStatus = roomStatusRepository.FindById(id);
            return View(roomStatus);
        }

        //
        // GET: /RoomStatus/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /RoomStatus/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                RoomStatu roomStatus = new RoomStatu();
                UpdateModel(roomStatus);
                roomStatusRepository.Add(roomStatus);
                roomStatusRepository.Commit();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /RoomStatus/Edit/5
 
        public ActionResult Edit(int id)
        {
            RoomStatu roomStatus = roomStatusRepository.FindById(id);
            return View(roomStatus);
        }

        //
        // POST: /RoomStatus/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
                RoomStatu roomStatus = roomStatusRepository.FindById(id);
                UpdateModel(roomStatus);
                roomStatusRepository.Commit();
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /RoomStatus/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /RoomStatus/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
